﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lg.Core.Encryption
{
    public class MD5
    {
        public static string Encrypt(string str)
        {
            if (!string.IsNullOrEmpty(str))
            {
                using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                {
                    string md5Str = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", "");
                    return md5Str;
                }
            }
            else
            {
                throw new Exception("未提供有效的明文!");
            }
            
        }
    }
}
